function lastSubstring(s: string): string {
    const sArr: string[] = s.split('')
    let maxStr: string = sArr[0]
    for (let i=0;i<sArr.length;i++) {
        maxStr = maxStr > sArr[i] ? maxStr : sArr[i]
    }
    let ans:string = s[0]
    sArr.forEach((item,index) => {
        if(item === maxStr) {
            ans = ans > s.substring(index) ? ans : s.substring(index)
        }
    })
    return ans
};


const s: string = "utzjfubnvzdimieuxrdxcsstfvlraliryhobrtupvasrheqxwdyvjvzrpigrnhglpaodkxjhgxakgqonxqchaokxwgxntpirmntipyjfdicpvgadhiykxitssrycjnoxszzrpfhbcalxdfeqmxjnumpabthahuxwqeyvjxxiwvtehyhvzejdgzkkqpcatsydglccxlhgijevyqfyssahxyuwdvjjmrmbahpkbppkhjrteomlfcunjfqfvdiboanivuielghfafmzqwxztogjedvkncthsbcotxkslalalvwirvdkfcnuixevbsennvwocqzfaslkbbfzfukcyvlhdhjsnfowjdzpjemobqpickfeinzvbltedjzfwshxeuiiphxcskhbyarzkcqfcaodhwzznhbwkybkhbnwfcdwttufdlaoomuxddafkvnwjthysfkzipnpenilqhntnffstyinoxwcfxmuaavdknpvejqorbbysfvbyaqgeqiwlouinmqgqcdibzsjbuhapzosxaxywkpbsagialvnfzngqvqnyjwudujclilfvmnqwgiondrbioqlmrjkszenvmdkvybmrqjcvqgctaqtsjtonkojbckaevdcwryywdtsiftjeemelqupfuxfuuuniioskyzojxnhkynqbfnpyxifttnzbljfsgcrcgmgcecomlhwcarqhlauyteodhhlskisszafqzziszioqxhjcxszzneiifddhftrhuenijkvprmduabggemixuuwnosyxaorzgzimvevvqtmdriivoxdriojvduaqywokjxgwihxiisuoidiyyuffgnakwbwhpwwlrycoubbadhffrzxmzoljuaiikukusysoentunltudryjitouxhkbybjstunrzgfdkxeiwjfnzrywdlcltmgekggawpqthgbvmmskbjfddapvrvisadnpkbdmbxrhwrsmrlgzmejddzcbjfirlh"
console.log(lastSubstring(s))